import React from "react";
import { Button, Form, Input } from "antd";
import "./less/login.less";
import logoImg from "../assets/img/login.png";
import {Link,useNavigate} from "react-router-dom"
import { LockOutlined, UserOutlined } from "@ant-design/icons";
export default function Login() {
  const navigator = useNavigate()
  const onFinish = (values) => {
    console.log("Success:", values);
    localStorage.setItem('avatar','tou.jpeg');
    localStorage.setItem('username','admin');
    navigator('/')
  };

  const onFinishFailed = (errorInfo) => {
    console.log("Failed:", errorInfo);
  };
  return (
    <div className="login">
      <div className="login_box">
        <img src={logoImg}></img>
        <Form
          name="basic"
          initialValues={{
            remember: true,
          }}
          onFinish={onFinish}
          onFinishFailed={onFinishFailed}
          autoComplete="off"
        >
          <Form.Item
            name="username"
            rules={[
              {
                required: true,
                message: "请输入用户名!",
              },
            ]}
          >
            <Input
              prefix={<UserOutlined className="site-form-item-icon" />}
              placeholder="请输入用户名"
            />
          </Form.Item>

          <Form.Item
            name="password"
            rules={[
              {
                required: true,
                message: "请输入密码!",
              },
            ]}
          >
            <Input.Password
              prefix={<LockOutlined className="site-form-item-icon" />}
              placeholder="请输入密码"
            />
          </Form.Item>

          <Form.Item>
            <Link to="/register">还没账号?立即注册</Link>
          </Form.Item>
          <Form.Item>
            <Button type="primary" htmlType="submit" size='large' block>
              登录
            </Button>
          </Form.Item>
        </Form>
      </div>
    </div>
  );
}
